package com.imooc.framework.stream;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class Employee {
    public Employee(String name, Integer age, Double salary, String sex, String dept) {
        this.name = name;
        this.age = age;
        this.salary = salary;
        this.sex = sex;
        this.dept = dept;
    }

    private String name;
    private Integer age;
    private Double salary;
    private String sex;
    private String dept;

    @Override
    public String toString() {
        return "Employee{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", salary=" + salary +
                ", sex='" + sex + '\'' +
                ", dept='" + dept + '\'' +
                '}';
    }

    public static List<Employee> getEmpList(){
        List<Employee> list = new ArrayList<>();
        list.add(new Employee("老张",40,9000d,"男","营业部"));
        list.add(new Employee("小刘",24,5000d,"女","开发部"));
        list.add(new Employee("大刚",32,7500d,"男","销售部"));
        list.add(new Employee("翠花",28,5500d,"女","销售部"));
        list.add(new Employee("小马",21,3000d,"男","开发部"));
        list.add(new Employee("老王",35,6000d,"女","人事部"));
        list.add(new Employee("小王",21,3000d,"女","人事部"));
        return list;
    }

//    @Override
//    public int compareTo(Object o) {
//        Employee other = (Employee) o;
//        // 在按照age属性排序
//        if (this.age > other.getAge())
//            return 1;
//        if (this.age < other.getAge())
//            return -1;
//        return 0;
//    }

    @Override
    public boolean equals(Object o) {
        Employee otherEmployee = (Employee) o;
        //只有name 和 address 相等，也算相等
        if (this.getDept().equals(otherEmployee.getDept())){
            return true;
        }else {
            return false;
        }
    }
}
